package com.mojo.concurrent.waitandnotify;

import java.util.concurrent.*;

/**
 * @author <a href="mailto:sjj@jianzhimao.com">mojo</a>
 * copyright (C), 2013-2023, 广州九尾信息科技有限公司
 * @date 2023/2/22 11:42
 */
public class ThreadExceptionDemo {
    static ExecutorService executor = Executors.newFixedThreadPool(2);

    public static void main(String[] args) throws InterruptedException {
        // executor.execute(new Runnable() {
        //     @Override
        //     public void run() {
        //         System.out.println(">>>>>>");
        //         int i = 1 / 0;
        //     }
        //
        // });
        // executor.shutdown();

        Thread thread = new Thread() {
            @Override
            public void run() {
                // 模拟非守护线程不退出情况
                while (true) {
                    try {
                        Thread.sleep(2000L);
                    } catch (InterruptedException e) {
                        throw new RuntimeException(e);
                    }
                    System.out.println(">>>>>");
                }
            }
        };
        thread.start();
        TimeUnit.SECONDS.sleep(2);
        System.out.println(thread.isDaemon());
        // 出线程退出
        System.out.println(">>>>主线程退出");
    }
}
